package handler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import service.TestService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class AddEntity {
    @Autowired
    private TestService service;

    @RequestMapping(path = "/add", method = RequestMethod.POST)
    public String handleRequest(
            // @RequestParam注解用于将请求的指定参数与指定处理器方法中的指定参数绑定
            @RequestParam(value = "param") String field,
            HttpServletRequest req, HttpServletResponse resp) {
        service.add(field);
        return "index";
    }
}
